var newsTable;
function getNewsList() {
    if (typeof newsTable !== 'undefined') {
        newsTable.fnPageChange('first');
        return;
    }
    var i = 1;
    newsTable = $("#newsList").DataTable({
        "sAjaxSource": _path + "/article/queryByPages",
        "fnServerParams": function (aoData) {
            aoData.push(
                { "name": "columnId", "value": $("#columnId").val() || $("#pid").val() },
                { "name": "status", "value": $("#status").val() },
                { "name": "fromDate", "value": $("#fromDate").val() },
                { "name": "toDate", "value": $("#toDate").val() },
                { "name": "keyType", "value": $("#keyType").val() },
                { "name": "keywords", "value": $("#keywords").val() }
            );
        },
        "sServerMethod": "POST",
        "sAjaxDataProp": "dataList",
        "fnCreatedRow": function () {
            i++;
        },
        "fnPreDrawCallback": function () {
            i = 1;
        },
        "aoColumns": [
            { "sTitle": "序号", "sWidth": "2%",
                "mData": function () {
                    return i;
                }
            },
            { "sTitle": "标题", "mData": "title", "sWidth": "10%" },
            { "sTitle": "栏目", "mData": "cv.value0", "sWidth": "10%" },
            { "sTitle": "状态", "mData": "status", "sWidth": "10%",
                "mRender": function (data) {
                    var status = '';
                    switch (data) {
                        case '0':
                            status = '未审核';
                            break;
                        case '1':
                            status = '审核通过';
                            break;
                        case '2':
                            status = '审核不通过';
                            break;
                        default :
                            status = '未知';
                            break;
                    }
                    return status;
                }
            },
            { "sTitle": "发布时间", "mData": "createTime", "sWidth": "10%" },
            { "sTitle": "操作", "sWidth": "10%",
                "mData": function (data) {
                    var status = '<a href="' + _path + '/article/edits/' + data.id +'" class="btn default btn-xs purple"><i class="fa fa-edit" title="审核通过"></i></a>';
                    status += '&nbsp;<a href="' + _path + '/article/dels/' + data.id + '"  class="btn default btn-xs red"><i class="fa fa-trash-o" title="删除"></i></a>';
                    return status;
                }
            }
        ]
    });
}